<?php
set_time_limit(0);
 
$canDo='y';
if (isset($_POST['op']) && isset($_POST['nianji']) &&  isset($_POST['phone'])){
    include '../c/config.php';
    $openid=trim($_POST['op']);
    $phone=trim($_POST['phone']);
    $nianji=trim($_POST['nianji']);

    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
 
    $count=0;
    if (3 == $nianji) {
    	$query=$mysqli->query("SELECT COUNT(id) as count FROM `d3` WHERE `uid`='".$openid."' AND `phone` = '".$phone."'");
    	$getData=$query->fetch_assoc();
    	$count=$getData['count'];
        if ($count > 1) {
        	$canDo='n';
        }
    	 
        
    }
    if (4 == $nianji) {
    	$query=$mysqli->query("SELECT COUNT(id) as count FROM `d4` WHERE `uid`='".$openid."' AND `phone` = '".$phone."'");
    	$getData=$query->fetch_assoc();
    	$count=$getData['count'];
        if ($count > 1) {
        	$canDo='n';
        }
        
    }
    if (5 == $nianji) {
    	$query=$mysqli->query("SELECT COUNT(id) as count FROM `d5` WHERE `uid`='".$openid."' AND `phone` = '".$phone."'");
    	$getData=$query->fetch_assoc();
    	$count=$getData['count'];
        if ($count > 1) {
        	$canDo='n';
        }
       
    } 	 
	 
    echo json_encode(array('s'=>$canDo,'d'=>$count));
}else{
    echo json_encode(array('s'=>$canDo));
}

?>